package stz.flash.main.flashlight.field;

import net.rim.device.api.system.Bitmap;
import stz.flash.Info;
import stz.flash.main.FlashTimer;
import stz.flash.main.ImageXY;
import blackberry.util.field.DjNonHighlightBitmapField;
import blackberry.util.image.DjImageResizer;

public class LedField extends HighlightManagerForFlashMode {
	
	private static final String FILE_NAME_OF_LED = "LED.png";
	
	public LedField() {
		super(Info.COLOR_OF_FOCUS,
				Info.COLOR_OF_SELECT,
				Info.GLOBAL_ALPHA_OF_HIGHLIGHT,
				null);
		add(new DjNonHighlightBitmapField(
				DjImageResizer.fitIntoDisplay(
						Bitmap.getBitmapResource(FILE_NAME_OF_LED), 
						ImageXY.WIDTH_OF_TEXT_IMAGE, 
						ImageXY.HEIGHT_OF_TEXT_IMAGE, 
						ImageXY.WIDTH_OF_VIRTUAL_IMAGE, 
						ImageXY.HEIGHT_OF_VIRTUAL_IMAGE, 
						0, Bitmap.FILTER_BILINEAR), 
				FOCUSABLE));
	}
	
	public void execute() {
		toggleLED();
	}
	
	public static void toggleLED() {
		FlashTimer.getIns().stopAndStart(FlashTimer.STOP_AND_START_led_toggle);
	}
	
	protected void onFocus(int i) {
		super.onFocus(i);
	}
	
	protected void onUnfocus() {
		super.onUnfocus();
	}
}
